package io.babystar.modules.business.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.babystar.common.utils.PageUtils;
import io.babystar.modules.business.dao.StudentManageFollowDao;
import io.babystar.modules.business.entity.StudentManageEntity;
import io.babystar.modules.business.entity.StudentManageFollowEntity;
import io.babystar.modules.business.service.StudentManageFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


@Service("studentManageFollowService")
public class StudentManageFollowServiceImpl extends ServiceImpl<StudentManageFollowDao, StudentManageFollowEntity> implements StudentManageFollowService {
    @Autowired
    StudentManageFollowDao manageFollowDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        /*IPage<StudentManageFollowEntity> page = this.page(
                new Query<StudentManageFollowEntity>().getPage(params),
                new QueryWrapper<StudentManageFollowEntity>()
        );*/
        Page<StudentManageEntity> page = new Page<>();
        page.setTotal(manageFollowDao.queryByPageCount(params));
        Integer pageNumber = Integer.parseInt(params.get("page").toString());
        Integer pageSize = Integer.parseInt(params.get("limit").toString());
        page.setCurrent(pageNumber);
        page.setSize(pageSize);
        Long current = page.getCurrent();
        Long size = page.getSize();
        Long currentStart = size*current - size;
        params.put("currentStart",currentStart);
        params.put("size",size);
        page.setRecords(manageFollowDao.queryByPage(params));

        return new PageUtils(page);
    }

}